import { createCrudApi } from '@/utils/apiFactory';
import request from '@/utils/unirequest';
import type { IPageResponse } from '@/type/common';
import type { ISysHrStaffNeedRequestBill, ISysHrStaffNeedRequestBillView, ISysHrStaffNeedRequestBillVm, ISysHrStaffNeedRequestBillEntryView } from './interface';

export default function SysHrStaffNeedRequestBillApi() {
  // 基础CRUD用工厂生成
  const baseCrud = createCrudApi<
    ISysHrStaffNeedRequestBillView,
    ISysHrStaffNeedRequestBillVm,
    ISysHrStaffNeedRequestBill
  >('/api/SysHrStaffNeedRequestBill');

  return {
    ...baseCrud,
    // 额外的特殊接口
    //查询用人需求明细列表
    async searchList(data: { HrStaffNeedId?: string, Limit: number, Page: number }): Promise<IPageResponse<ISysHrStaffNeedRequestBillEntryView[]>> {
      return await request.post('/api/SysHrStaffNeedRequestBillEntry/Search', data);
    },
    // 审核接口
    async approve(data: ISysHrStaffNeedRequestBillVm): Promise<ISysHrStaffNeedRequestBill> {
      return await request.post('/api/SysHrStaffNeedRequestBill/approve?tag=', data);
    },
  };
}
